<?php
class AddToGroup extends Action {
	/* (non-PHPdoc)
	 * @see Action::execute()
	 */
	public function execute($params) {
		check_login ( ADMIN_LOGIN_PAGE );
		$uid = irqst ( 'uid' );
		$gids = safe_ids ( rqst ( 'gids' ), ',', true );
		$data ['success'] = true;
		if (empty ( $uid ) || empty ( $gids )) {
			$data ['success'] = false;
			$data ['msg'] = '用户编号或组编号为空,操作无法进行。';
		} else {
			$guM = new CoreGroupUserModel ();
			$rst = $guM->addToGroup ( $uid, $gids );
			if (! $rst) {
				$data ['success'] = false;
				$data ['msg'] = '数据库操作失败：' . $guM->last_error_msg ();
			}
		}
		return new JsonView ( $data );
	}
}